package com.project.hqshorttaxi.service.impl;

import com.project.hqshorttaxi.dto.*;
import com.project.hqshorttaxi.entity.ShortDistance;
import com.project.hqshorttaxi.mapper.ShortDistanceMapper;
import com.project.hqshorttaxi.service.ShortDistanceService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ShortDistanceServiceImpl implements ShortDistanceService {

    @Resource
    private ShortDistanceMapper shortDistanceMapper;

    @Override
    public ShortDistance getById(Integer id) {
        return shortDistanceMapper.selectByPrimaryKey(id);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void insert(ShortDistance entity) throws Exception {
        shortDistanceMapper.insertSelective(entity);
    }

    @Override
    public List<ShortDistanceDto> list(ShortDistanceParam param) {
        List<ShortDistanceDto> list = shortDistanceMapper.getList(param);
        return list;
    }

    @Override
    public List<ShortDistance> boardList(BoardParam param) {
        return shortDistanceMapper.getBoardList(param);
    }

    @Override
    public ShortDistance getByPlateAndDate(ShortDistanceParam param) {
        List<ShortDistance> list = shortDistanceMapper.getByPlateAndDate(param);
        return list.size() == 0 ? null : list.get(0);
    }

    @Override
    public List<ShortDistanceStatDto> getTotal(ShortDistanceStatParam param) {
        return shortDistanceMapper.getTotal(param);
    }

    @Override
    public List<ShortDistanceStatDto> getTotalAll(ShortDistanceStatParam param) {
        return shortDistanceMapper.getTotalAll(param);
    }

    @Override
    public List<ShortDistanceStatDto> getTotalByRefuse(ShortDistanceStatParam param) {
        return shortDistanceMapper.getTotalByRefuse(param);
    }

    @Override
    public List<ShortDistanceExcelDto> getOutputList(ShortDistanceParam param) {
        List<ShortDistanceExcelDto> list = shortDistanceMapper.getOutputList(param);
        return list;
    }

    @Override
    public List<ShortDistance> getExportByPlateAndDate(ShortDistanceParam param) {
        List<ShortDistance> list = shortDistanceMapper.getExportByPlateAndDate(param);
        return list;
    }

    @Override
    public List<ShortDistance> getExportByPlateAndDate2(ShortDistanceParam param) {
        List<ShortDistance> list = shortDistanceMapper.getExportByPlateAndDate2(param);
        return list;
    }
}
